window.onload = function() {
    var mySwiper = new Swiper(".swiper-container", {
        loop: true, // 循环模式选项

        // 如果需要分页器
        pagination: {
            el: ".swiper-pagination",
            clickable: true,
        },
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
        autoplay: {
            delay: 2500, //事件间隔
            stopOnLastSlide: false, //
            disableOnInteraction: false,
            pauseOnMouseEnter: true, //输入移入 停止
        },
    });



    var control = document.getElementById('control')
    var controlnone = document.getElementById('controlnone')
    var controlnoneswi = document.getElementById('controlnone-swi')
    var logo = document.getElementById('logo')
    control.onmouseover = function() {
        controlnone.style.display = 'block'
    }
    controlnoneswi.onmouseover = function() {
        controlnone.style.display = 'none'
    }
    logo.onmouseover = function() {
        controlnone.style.display = 'none'
    }


    var nav = document.querySelectorAll('.nav_item');
    var tab = document.querySelectorAll('.tab')
    nav = [...nav];
    tab = [...tab];
    nav.forEach(function(item, index) {
        item.addEventListener('click', function(e) {
            nav.forEach(function(item) {
                item.className = 'nav_item'
            })

            tab.forEach(function(item) {
                item.className = 'tab'
            })
            this.className = 'nav_item active';
            tab[index].className = 'tab show'
        })
    })
    for (var i = 0; i < nav.length; i++) {
        (function() {
            var x = i;
            nav[i].onclick = function() {
                this.style.color = '#000'
                var cname = item.className;
                for (var j = 0; j < nav.length; j++) {
                    nav[j].className = cname

                }
                nav[x].className = canme + 'active'

            }
        })()
    }
    //index 用户展示
    if (localStorage.getItem('username')) {
        let yhm = document.querySelector('.wrapper-right-sp');
        console.log(yhm);
        yhm.innerHTML = "您好," + localStorage.getItem("username") + '<a href = "login.html" id = "exit" >退出</a>';
    }

    let exit = document.querySelector('#exit');
    exit.addEventListener('click', function() {
        localStorage.removeItem('username');
        setTimeout(() => {
            location.href = "login.html";
        }, 1000);
    })

}